import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 23735
 * Date: 2022-09-30
 * Time: 10:22
 */
import java.util.Scanner;
import java.util.Scanner;
class BTNode{
    public char val;
    public BTNode left;
    public BTNode right;
    public BTNode(char val){
        this.val=val;
    }
}
public class Main{
    public static int i=0;
    public static void main(String []args){
        String str=new String();
        Scanner scanner=new Scanner(System.in);
        while(scanner.hasNext()){
            str=scanner.next();
            i=0;
            BTNode root=restore(str);
            inOrder(root);
        }
    }

    public static BTNode restore(String str){
        if(i>=str.length()){
            return null;
        }
        char ch=str.charAt(i);
        if(ch=='#'){
            //注意返回之前i++;
            i++;
            return null;
        }
        BTNode nodeParent=new BTNode(ch);
        i++;
        BTNode nodeLeft=restore(str);
        BTNode nodeRight=restore(str);
        nodeParent.left=nodeLeft;
        nodeParent.right=nodeRight;
        return nodeParent;
    }

    public static void inOrder(BTNode root){
        if(root==null){
            return ;
        }
        inOrder(root.left);
        System.out.print(root.val+" ");
        inOrder(root.right);
    }
}